package com.baimsg.reader.network

import com.baimsg.reader.bean.BookBean
import com.baimsg.reader.bean.BookContentBean
import com.google.gson.Gson

/**
 * Create by Baimsg on 2022/3/23
 *
 **/
object ApiInterface {

    private val GSON by lazy {
        Gson()
    }

    private const val baseUrl = "https://yuedu.163.com/"


    fun getBookInfo(id: String, tradeId: String = ""): BookBean? {
        val str = HttpUtils.exeGet("${baseUrl}getBook.do?id=$id&tradeId=$tradeId")
        if (str.isNullOrBlank()) {
            return null
        }
        return GSON.fromJson(str, BookBean::class.java)
    }

    fun getArticleContent(sourceUuid: String, articleUuid: String, bigContentId: String): BookContentBean? {
        val str =
            HttpUtils.exeGet("${baseUrl}getArticleContent.do?sourceUuid=$sourceUuid&articleUuid=$articleUuid&bigContentId=$bigContentId")
        if (str.isNullOrBlank()) {
            return null
        }
        return GSON.fromJson(str, BookContentBean::class.java)
    }
}

